package com.ruoyi.houses.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.uuid.SnowFlake;
import com.ruoyi.houses.domain.Houses;
import com.ruoyi.houses.mapper.HousesMapper;
import com.ruoyi.houses.service.IHousesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 房屋信息列表Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-09-13
 */
@Service
public class HousesServiceImpl implements IHousesService
{
    @Autowired
    private HousesMapper housesMapper;

    /**
     * 查询房屋信息列表
     * 
     * @param id 房屋信息列表主键
     * @return 房屋信息列表
     */
    @Override
    public Houses selectHousesById(Long id)
    {
        return housesMapper.selectHousesById(id);
    }

    /**
     * 查询房屋信息列表列表
     * 
     * @param houses 房屋信息列表
     * @return 房屋信息列表
     */
    @Override
    public List<Houses> selectHousesList(Houses houses)
    {
        return housesMapper.selectHousesList(houses);
    }

    /**
     * 新增房屋信息列表
     * 
     * @param houses 房屋信息列表
     * @return 结果
     */
    @Override
    public int insertHouses(Houses houses)
    {
        SnowFlake snowFlake = new SnowFlake(1, 1);
        long id = snowFlake.nextId();
        houses.setId(id);
        houses.setCreateTime(DateUtils.getNowDate());
        return housesMapper.insertHouses(houses);
    }

    /**
     * 修改房屋信息列表
     * 
     * @param houses 房屋信息列表
     * @return 结果
     */
    @Override
    public int updateHouses(Houses houses)
    {
        houses.setUpdateTime(DateUtils.getNowDate());
        return housesMapper.updateHouses(houses);
    }

    /**
     * 批量删除房屋信息列表
     * 
     * @param ids 需要删除的房屋信息列表主键
     * @return 结果
     */
    @Override
    public int deleteHousesByIds(Long[] ids)
    {
        return housesMapper.deleteHousesByIds(ids);
    }

    /**
     * 删除房屋信息列表信息
     * 
     * @param id 房屋信息列表主键
     * @return 结果
     */
    @Override
    public int deleteHousesById(Long id)
    {
        return housesMapper.deleteHousesById(id);
    }
}
